package com.scoresystem.utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JdbcUtil {
	private String url="jdbc:mysql://localhost:3306/scoresystem";
	private String username="root";
	private String password="";
	private static JdbcUtil instance=new JdbcUtil();
	
	private JdbcUtil(){}
	
	public static JdbcUtil getInstance(){
		return instance;
	}
	static{
		try {
			System.setProperty("jdbc.drivers", "com.mysql.jdbc.Driver");
			Class.forName("com.mysql.jdbc.Driver");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}
	
	public Connection getConnection() throws SQLException{
		return DriverManager.getConnection(url,username,password);
		
	}
	
	public void free(Connection conn) {

		try {
			if (conn != null)
				conn.close();
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}
